<template>
  <div class="button_add">
    <el-input v-model="search.name"
              placeholder="输入部门名称查询">
    </el-input>
    <el-button type="primary" @click=" getTableData">
      <el-icon>
        <Search></Search>
      </el-icon>
      查询
    </el-button>
  </div>

  <el-tree
      style="width: 100%; "
      :data="listEnterprise"
      :props="defaultProps"
  />

</template>

<script lang="ts" setup>
import {onMounted, reactive, ref} from "vue";
import {getEnterpriseApi} from "@/api/admin";


const listEnterprise:any = ref([])

const defaultProps = {
  children: 'sections',
  label: 'name',
}
const search = reactive({name: ""})

function getTableData() {
  getEnterpriseApi(search).then((response: any) => {
    listEnterprise.value =[{name: "测盟汇", sections:[...response.data]}]
  })
}

onMounted(() => {
  getTableData()
})
</script>

<style scoped>

</style>
